<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件绑定</title>
    <script src="./js/vue.js"></script>
</head>
<body>
<div id="app">
    <input type="button" value="-" @click="decrease(1)">
    {{sum}}
    <input type="button" value="+" @click="increase(1)">
</div>

<script>
    new Vue({
        el: "#app",
        data: {
            sum : 0
        },
        methods : {
            increase : function (num) {
                this.sum +=num
            },
            decrease: function (num){
                if (this.sum <=1){

                }else {
                    this.sum -=num
                }

            }
        }
    });
</script>
</body>
</html>